package com.itheima.yuanzixing;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

public class Demo01 {
    public static void main(String[] args) throws InterruptedException {
        Song song = new Song();
        ExecutorService pool = Executors.newCachedThreadPool();
        for (int i = 0; i < 100; i++) {
            pool.submit(song);
        }
        Thread.sleep(2000);

        System.out.println(Song.count.get());
    }


}

class Song implements Runnable {
    volatile static AtomicInteger count=new AtomicInteger();


    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
          //  synchronized (this) {
                count.incrementAndGet();//查看count 的值   count =count+1
           // }
        }
    }
}
